package com.shiguiwu.springmybatis.algorithm.search;

import com.shiguiwu.springmybatis.algorithm.sort.SortTests;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * @description: 查找算法
 * @author: stone
 * @date: Created by 2021/4/8 22:42
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.algorithm.search
 */
@Slf4j
public class SearchTests {
    public static void main(String[] args) {
        int[] arrays = {2, 2, 2, 3, 4, 5, 5, 6, 7, 8};//sortArrays(10);
        System.out.println(Arrays.toString(arrays));
        Search search = new BinarySearch(arrays);
        int index = search.search(0);
        int[] array = search.searchArrays(2);
        log.info(String.valueOf(index));
        log.info(Arrays.toString(array));

        search = new InsertValSearch(arrays);
        int index1 = search.search(8);

        log.warn("查找的值的索引是 ===> {}",index1);
    }

    public static int[] sortArrays(int size) {
        int[] init = SortTests.init(size);
        Arrays.sort(init);
        return init;
    }

}
